package com.maikec.utils.mybatis.provider;

import org.apache.ibatis.jdbc.SQL;

/**
 * update代理类
 * @author maikec
 * @date 2018/7/13
 */
public class UpdateProvider<T> implements Provider{
    /**
     * update
     * @param t t
     * @return sql
     * @throws Exception exception
     */
    public String update(T t) throws Exception{
        if (null == t) {
            throw new NullPointerException(t.getClass().getName() + " is null");
        }
      return new SQL() {
            {
                UPDATE(getTableName(t));
                SET(getSql(t, true));
                WHERE(getIdCondition(t));
            }
        }.toString();
    }
}
